import Vue from "vue";
import VueRouter from "vue-router";
import Index from "../views/Index.vue";
import ShoppingCar from "../views/ShoppingCar.vue";
import TypeCake from "../views/TypeCake.vue";
import Me from "../views/Me.vue";
import CakeDetail from "../views/CakeDetail.vue";
import Login from "../views/Login.vue";
import Register from "../views/Register.vue";
Vue.use(VueRouter);

const routes = [
  {
    path: "/button",
    name: "Button",
    component: () => import("../testing/button.vue"),
  },
  {
    path: "/",
    name: "Index",
    meta: {
      showHeader: true,
      showFooter: true,
      title: "首页-味多美",
      keepAlive: false, // 不需要缓存
    },
    component: Index,
  },
  {
    path: "/shoppingCar",
    name: "ShoppingCar",
    meta: {
      showHeader: false,
      showFooter: true,
      title: "购物车-味多美",
      keepAlive: false, // 不需要缓存
    },
    component: ShoppingCar,
  },
  {
    path: "/typecake",
    name: "TypeCake",
    meta: {
      showHeader: true,
      showFooter: true,
      title: "蛋糕列表-味多美",
      keepAlive: true, // 需要缓存
    },
    component: TypeCake,
  },
  {
    path: "/me",
    name: "Me",
    meta: {
      showHeader: false,
      showFooter: true,
      title: "用户信息-味多美",
      keepAlive: false, // 不需要缓存
    },
    component: Me,
  },
  {
    path: "/cakedetail",
    props: true,
    name: "CakeDetail",
    meta: {
      showHeader: false,
      showFooter: false,
      title: "蛋糕详情-味多美",
      keepAlive: false, // 不需要缓存
    },
    component: CakeDetail,

  },
  {
    path: "/login",
    name: "Login",
    meta: {
      showHeader: false,
      showFooter: false,
      title: "登录-味多美",
      keepAlive: false, // 不需要缓存
    },
    component: Login,
  },
  {
    path: "/register",
    name: "Register",
    meta: {
      showHeader: false,
      showFooter: false,
      title: "注册-味多美",
      keepAlive: false, // 不需要缓存
    },
    component: Register,
  }
];

const router = new VueRouter({
  mode: "history",
  base: process.env.BASE_URL,
  routes,
});

export default router;
